﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using FXSStation.Modules.SharedInfrastructureModule.BusinessClasses.Accounts;
using System.Collections.ObjectModel;
using FXSStation.Modules.SharedInfrastructureModule.BusinessClasses.Orders;
using FXSStation.Modules.SharedInfrastructureModule.BusinessClasses.Currency;

namespace FXSStation.Modules.SharedInfrastructureModule.BusinessClasses.Reports
{
    [Serializable]
    public class ReportBase : INotifyPropertyChanged
    {
        private Account _account;
        public Account Account
        {
            get
            {
                return _account;
            }
            set
            {
                if (_account != value)
                {
                    _account = value;
                    RaisePropertyChanged("Account");
                }
            }
        }

        private decimal _profit;
        public decimal Profit
        {
            get
            {
                return _profit;
            }
            set
            {
                if (_profit != value)
                {
                    _profit = value;
                    RaisePropertyChanged("Profit");
                }
            }
        }

        private ObservableCollection<OrderBase> _orders;
        public ObservableCollection<OrderBase> Orders
        {
            get
            {
                return _orders;
            }
            set
            {
                _orders = value;
            }
        }

        // AF - Added for Reporting purposes.

        //public IQueryable<OrderBase> BuyOrders
        //{
        //    get
        //    {
        //        return (from order in Orders
        //                where order.Type == OrderType.BuyOrder
        //                select order).AsQueryable<OrderBase>();
        //    }
        //}
        //public IQueryable<OrderBase> SellOrders
        //{
        //    get
        //    {
        //        return (from order in Orders
        //                where order.Type == OrderType.SellOrder
        //                select order).AsQueryable<OrderBase>();
        //    }
        //}

        private CurrencyEnum _currency;
        public CurrencyEnum Currency
        {
            get
            {
                return _currency;
            }
            set
            {
                if (_currency != value)
                {
                    _currency = value;
                    RaisePropertyChanged("Currency");
                }
            }
        }

        private DateTime _startDate;
        public DateTime StartDate
        {
            get
            {
                return _startDate;
            }
            set
            {
                if (_startDate != null)
                {
                    _startDate = value;
                    RaisePropertyChanged("StartDate");
                }
            }
        }

        private DateTime _endDate;
        public DateTime EndDate
        {
            get
            {
                return _endDate;
            }
            set
            {
                if (_endDate != value)
                {
                    _endDate = value;
                    RaisePropertyChanged("EndDate");
                }
            }
        }

        private ReportType _type;
        public ReportType Type
        {
            get { return _type; }
            protected set { _type = value; }
        }

        //public ReportBase(ReportType type)
        //{
        //    this._type = type;
        //}

        ///// <param name="account">Account of the Report</param>
        //public ReportBase(Account account, ReportType type)
        //{
        //    this._account = account;
        //    this._type = type;
        //}
        
        #region INotifyPropertyChanged Members
        [field:NonSerialized]
        public event PropertyChangedEventHandler PropertyChanged;
    
        public virtual void RaisePropertyChanged(string propertyName)
        {
            if (PropertyChanged != null)
                PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
        }

        #endregion
    }
}
